<?php 
	include("header.php");
	include("top_menu.php");
?>
<?php
	if (isset($_POST['add'])) {
?>
	<title>
		Adding new device
	</title>
	<div class = 'header-adding'>
		Adding new device
	</div>
	<form action = "savedevice.php" method = "POST">
		<div class = 'adding-c1'>
			<input type = "text" name = "name" maxlength = '40' placeholder = ' Enter name of new device' size = '50' class = 'bordered_input'/> 
		</div>
		<div class = 'adding-c2'>
			<input type = "submit" value = "Add" class = "button"/>
		</div>
	</form>
<?php 
	} else {
		session_start();
		$connection = mysql_pconnect("localhost" , "root" , "31122001");
		mysql_select_db("kt_site");	
		$array = $_POST['devicestodelete'];
		if (!empty($array)) {
			$N = count($array);
			for ($i = 0 ; $i < $N ; $i++) {
				$device = $array[$i];
				$query = "DELETE FROM device_type WHERE id = '".$device."';";
				$result = mysql_query($query);
			}
		}
		echo "<meta http-equiv='Refresh' content='0; URL=showavailabledevices.php'>";
	}
?>
